home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13661 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  45 lines

  1. Path: jupiter.planet.net!usenet
  2. From: cygnusx@planet.net (David )
  3. Newsgroups: comp.lang.c
  4. Subject: HELP : Assignment with strings and pointers.
  5. Date: Tue, 09 Apr 1996 20:24:44 GMT
  6. Organization: Planet Access Networks - Stanhope, NJ
  7. Message-ID: <316ac5b5.4283622@news.planet.net>
  8. NNTP-Posting-Host: newt10.planet.net
  9. X-Newsreader: Forte Agent .99d/32.182
  10.  
  11.  
  12.  
  13. This program is probably idiotic since I am in a (intro to C ) class
  14. but it does work. I was wondering if anyone had a better idea for this
  15. type of situation. I could not find an actual function in the
  16. character handling library for this? does one exist ? i would like to
  17. make a separate function in the main to handle this task? Is it
  18. possible?
  19.  
  20. thanx David
  21.  
  22.  
  23.   #include <stdio.h>
  24.   #include <ctype.h>
  25.  
  26.    /* this program determines if the first word  is the second word
  27. spelled backwords and have only included 3 characters for
  28. simplification . inputs have been left out for clarity */
  29.  
  30.    main()
  31.    {
  32.  
  33.    char *ptr = "six";
  34.    char *atr = "xis";
  35.  
  36.    printf("%s\n",ptr);
  37.  
  38.    printf("%s\n",atr);
  39.  
  40.  if (*ptr==*(atr+2)&&*(ptr+1)==*(atr+1)&&*(ptr+2)==*atr)
  41. printf("okay");
  42.  
  43.              else printf("no good");
  44.    return 0; }
  45.